from base import _YamlHelper
from page import Page
from page.web_login_page import WebLoginPage


class AppraisePage(Page):

    appraise_yaml = _YamlHelper().get_config_as_dict('niushop23\\page\\appraise.yaml')['AppraisePage']
    def appraise_page(self,name,pwd):
        '''输入账户密码'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.web_login_page(name,pwd)

    def appraise_click(self):
        '''初始界面登录按钮'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.click()

    def get_forgetpwd_text(self):
        '''获取忘记密码文本'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        forgetpwd_text = login_page.login_text()
        return forgetpwd_text

    def get_username_text(self):
        '''获取用户名文本'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        username_text = login_page.login_after_text()
        return username_text

    def get_ready_appraise_text(self):
        '''获取待评价文本'''
        driver = self._driver
        appraise_text = driver.get_text(self.appraise_yaml['READY_APPRAISE_TEXT'])
        return appraise_text

    def get_need_appraise_text(self):
        '''获取我要评价文本'''
        driver = self._driver
        need_appraise_text = driver.get_text(self.appraise_yaml['NEED_TO_APPRAISE_TEXT'])
        return need_appraise_text

    def get_goods_appraise_text(self):
        '''获取对购买过的商品评价文本'''
        driver = self._driver
        bought_goods_text = driver.get_text(self.appraise_yaml['GOODS_APPRAISE_TEXT'])
        return bought_goods_text

    def mouse_stay(self):
        '''鼠标悬浮'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.move()

    def mycenter_to(self):
        '''点击个人中心切换新页面'''
        driver = self._driver
        driver.click(self.appraise_yaml['CLICK_PERSONAL_CENTER'])
        driver.switch_to_window_by_index(2)

    def ready_appraise_button(self):
        '''点击待评价按钮'''
        driver = self._driver
        driver.click(self.appraise_yaml['CLICK_READY_APPRAISE'])

    def need_appraise_button(self):
        '''点击我要评价按钮'''
        driver = self._driver
        driver.click(self.appraise_yaml['CLICK_NEED_APPRAISE'])

    def appraise_write(self):
        '''填写评价语'''
        driver = self._driver
        driver.type(self.appraise_yaml['APPRAISE_WORD_WRITE'],'不是最贵不买，不是Dior不做回头客')
        driver.forced_wait(2)

    def goods_submit_button(self):
        '''提交按钮'''
        driver = self._driver
        driver.click(self.appraise_yaml['SUBMIT_BUTTON'])

